package com.canic.dkd.authorization.staff.controller;

import com.canic.dkd.authorization.staff.entity.SysPermission;
import com.canic.dkd.authorization.staff.entity.SysRole;
import com.canic.dkd.authorization.staff.service.SysUserService;
import com.canic.dkd.base.entity.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户控制器
 * @author ZC
 * @since 2019-05-02
 */
@Slf4j
@RestController
@RequestMapping("/sysUser")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 查询某用户的所有权限
     * @return
     */
    @RequestMapping("/permissionOfUser")
    public Result permissionOfUser(){
        try{
            List<SysPermission> list = sysUserService.getPermissionListByUserId("2");
            return Result.successResult(list);
        }catch (Exception e){
            log.error(e.getMessage());
            return Result.failureResult(e.getStackTrace());
        }
    }

    /**
     * 查询某用户的所有角色
     * @return
     */
    @RequestMapping("/roleOfUser")
    public Result roleOfUser(){
        try{
            List<SysRole> list = sysUserService.getRoleListByUserId("2");
            return Result.successResult(list);
        }catch (Exception e){
            log.error(e.getMessage());
            return Result.failureResult(e.getStackTrace());
        }
    }

}

